//////////////////////////////////////
//// ASKIMA - COLLABORATOR PROFILE
//// IDENTITY MANAGEMENT FUNCTIONS
//////////////////////////////////////

function split(val) {
	return val.split(" ");
}

function extractLast(term) {
	return split(term).pop();
}

function initNationalitiesAutoComplete() {
	$("#nationalities").bind(
			"keydown",
			function(event) {
				if (event.keyCode === $.ui.keyCode.TAB
						&& $(this).data("autocomplete").menu.active) {
					event.preventDefault();
				}
			}).autocomplete(
			{
				minLength : 0,
				source : function(request, response) {
					response($.ui.autocomplete.filter(nationalities,
							extractLast(request.term)));
				},
				focus : function() {
					return false;
				},
				select : function(event, ui) {
					var terms = split(this.value);
					terms.pop();
					terms.push(ui.item.value);
					terms.push("");
					this.value = terms.join(" ");
					return false;
				}
			});
}

function showForm() {
	$("#identity_edit_panel").dialog({
		title : 'Modifier Etat Civil',
		width : 500
	});
}